home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
oper_sys
/
emerald
/
emrldsys.lha
/
Language
/
Compiler
/
evaluate.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-08-16
|
3KB
|
134 lines
/*
* @(#)evaluate.c 1.2 4/11/88
*/
#include "assert.h"
#include "error.h"
#include "scan.h"
#include "nodes.h"
#include "symbols.h"
#include "MyParser.h"
#include "sequence.h"
#include "semantics.h"
#include "system.h"
#include "flags.h"
#include "trace.h"
#include "builtins.h"
#include "map.h"
#include "evaluate.h"
#include "opNames.h"
#include "option.h"
#undef NULL
#include <sys/file.h>
#include "ndbm.h"
#undef NULL
DBM *emDBM;
extern char *emDirectory, *emdbDirectory;
#define NULL 0
extern NodePtr ownNameSig, ownTypeSig, ownNameOpDef, ownTypeOpDef;
extern OID ownNameOID, ownTypeOID;
Map manifestMap;
NodePtr findObjectOperation(object, opName)
NodePtr object, opName;
{
int stage;
NodePtr ops, anop, asig, aname;
register OID theID;
object = GETVALUE(object);
assert(object->tag == P_OBLIT);
assert(opName->tag == P_OPNAME);
theID = opName->b.opname.id;
for(stage = 0; stage < 2; stage++) {
if (stage == 0) {
ops = object->b.oblit.monitor;
if (ops != NULL) {
assert(ops->tag == P_MONITOR);
ops = ops->b.monitor.ops;
}
} else if (stage == 1) {
ops = object->b.oblit.ops;
}
Sequence_For(anop, ops)
assert(anop->tag == P_OPDEF);
asig = anop->b.opdef.sig;
assert(asig->tag == P_OPSIG);
aname = asig->b.opsig.name;
assert(aname->tag == P_OPNAME);
if (aname->b.opname.id == theID) {
return(anop);
}
Sequence_Next
}
/*
* It is possible that this is an invocation of ownName or ownType.
*/
if (theID == ownNameOID) {
return(ownNameOpDef);
} else if (theID == ownTypeOID) {
return(ownTypeOpDef);
} else {
return(NN);
}
}
void initializeManifest()
{
char mappath[100];
manifestMap = Map_Create();
sprintf(mappath, "%s/DB/db", emdbDirectory);
if ((emDBM = dbm_open(mappath, O_RDWR | O_CREAT, 0777)) <= 0) {
fprintf(stderr, "Could not open the data base file %s\n", mappath);
exit(1);
}
}
NodePtr figureOutAT(p)
register NodePtr p;
{
register Symbol st;
register NodePtr result = NULL;
if ((int) p <= 0x200) {
fprintf(stderr, "Strange value %d in figureOutAT.\n", (int)p);
assert(FALSE);
} else if (p->tag == P_ATLIT) {
result = p;
} else if (p->tag == P_BUILTINLIT) {
if (p->b.builtinlit.whichType != KARRAY &&
p->b.builtinlit.whichType != KVECTOR)
result = refToBuiltinFromToken(B_INSTAT, p->b.builtinlit.whichType);
} else if (p->tag == P_SYMREF) {
st = ST_Fetch(p->b.symref.symbol);
if (st->isManifest || st->hasValue) result = figureOutAT(st->value.value);
} else if (p->tag == P_OBLIT) {
if (p->b.oblit.instat != NULL) result = figureOutAT(p->b.oblit.instat);
} else if (p->tag == P_GLOBALREF) {
resolveGlobal(p, (ValuePtr)NULL);
result = figureOutAT(p->b.globalref.value);
} else {
NotImplemented(p, "Figuring out general ATs");
}
return(result);
}
void tryToSetCTInfo(st)
register Symbol st;
{
#ifdef JUNK
register NodePtr at, ct;
if (loadedDummyBuiltins) return;
at = st->value.ATinfo;
assert(at != NULL);
if (at->b.atlit.f.cannotBeConformedTo) {
if (at->b.atlit.codeOID == 0) return;
ct = OTLookup(at->b.atlit.codeOID);
if (ct == NN) return;
if (ct->tag != P_OBLIT) return;
st->value.CTinfo = ct;
}
#endif
}